/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dd2.Dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dds2.modelo.Product;

/**
 *
 * @author Piter
 */
@Stateless
public class ProductDao extends AbstractDao<Product> implements ProductDaoLocal {
    @PersistenceContext(unitName = "Farmacia-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ProductDao() {
        super(Product.class);
    }
    public boolean findDuplicity(Product product){
     Query q = em.createNamedQuery("Product.findByDuplicity");
     q.setParameter("nombre", product.getName());
     //q.setParameter("apellidoMaterno", product.());
     //q.setParameter("apellidoPaterno", product.getApellidoPaterno());
     return !q.getResultList().isEmpty();
 } 

    
}
